<template>
	<view>
		<view class="list">
			<view class="tips">可以让外来人员扫描此码，自助填写信息</view>
			<view>
				<view class="qrimg">
				    <view class="qrimg-i">
				    	<tki-qrcode v-if="ifShow" cid="qrcode2" ref="qrcode2" :val="val" :size="size" :onval="onval" :loadMake="loadMake" :usingComponents="true" @result="qrR" />
				    </view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	export default {
		components: {
			tkiQrcode,
		},
		data() {			
			return {
				oid : uni.getStorageSync("userinfo").oid,
				oname: uni.getStorageSync("userinfo").oname,
				ifShow: true,
				//微信的话这里要写死为小程序的二维码地址或者是H5平台的二维码地址 
				val:'',
				size: 350, // 二维码大小
				onval: true, // val值变化时自动重新生成二维码
				loadMake: true // 组件加载完成后自动生成二维码
			}
		},
		onShow() {		
			this.val = getApp().globalData.userurl+encodeURIComponent(encodeURI(`&oid=${this.oid}&oname=${this.oname}`).replace(/%/g, '%25'));
				// this.val = `${location.protocol}//${location.host}/#/pages/add-menber/add-menber?oid=${this.oid}`;
			console.log(this.val)
		},
		methods: {
			creatQrcode() {
				this.$refs.qrcode._makeCode()
			},
			qrR(res) {
				this.src = res
			},
			//修改密码
			modifyPwd() {
				uni.navigateTo({
					url: '/pages/change-pwd/change-pwd'
				})
			},
			//关于我们
			aboutUs() {
				uni.navigateTo({
					url: ''
				})
			},
			//退出
			exit() {
				uni.removeStorageSync('token')
				uni.removeStorageSync('username')
				uni.reLaunch({
					url: '/pages/login/login'
				})
			},
			newUser() {
				uni.navigateTo({
					url: '/pages/new-user/new-user'
				})
			}
		}
	}
</script>

<style>
	.list {
		padding: 20px 0px;
		text-align: center;
		border-top: solid 1px #DDDDDD;
	}

	.tips {
		line-height: 80px;
		font-size: 14px;
		color: #999999;
	}
</style>
